package tech.wetech.admin.modules.system.web;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import tech.wetech.admin.core.utils.HttpUtils;
import tech.wetech.admin.core.utils.PayUrl;
import tech.wetech.admin.modules.base.web.BaseCrudController;
import tech.wetech.admin.modules.system.po.SuiXingFu;
import tech.wetech.admin.modules.system.service.SuiXingFuService;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/suixingfu")
public class SuiXingFuController extends BaseCrudController<SuiXingFu> {

    @Autowired
    private SuiXingFuService suiXingFuService;

    @ResponseBody
    @PostMapping("/applyifo")
    public String applyInfo(String mno) {
        Map<String,Object> map=new HashMap<>();
        map.put("mno",mno);
        String json= HttpUtils.postsJson(PayUrl.suixingfu+"/suixingfu/commitApply.do",map);
        JSONObject jsonObject= JSON.parseObject(json);
        String jsonStr = JSONObject.toJSONString(jsonObject.get("data"));
        JSONObject dataObject=JSONObject.parseObject(jsonStr);
        if (jsonObject.getInteger("code")==200){
            return dataObject.getString("retUrl");
        }
        return "0";
    }

    @ResponseBody
    @PostMapping("/selectapplyifo")
    public int selectApplyifo(String mno) {
        Map<String,Object> map=new HashMap<>();
        map.put("mno",mno);
        String json= HttpUtils.postsJson(PayUrl.suixingfu+"/suixingfu/commitApplySelect.do",map);
        JSONObject jsonObject= JSON.parseObject(json);
        if (jsonObject.getInteger("code")==200){
            return 1;
        }
        return 0;
    }

    @ResponseBody
    @PostMapping("/setMnoArray")
    public int setMnoArray(String ids,String mno) {
        Map<String,Object> map=new HashMap<>();
        map.put("ids",ids);
        map.put("mno",mno);
        String json= HttpUtils.postsJson(PayUrl.suixingfu+"/suixingfu/setMnoArray.do",map);
        JSONObject jsonObject= JSON.parseObject(json);
        if (jsonObject.getInteger("code")==200){
            return 1;
        }
        return 0;
    }
}
